/**
*      author: Y_Yao
*      created: 2024-12-06 20:01:29
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 100 + 7;
int n,q;

void solve()
{
    cin >> n >> q;
    int l = 1,r = 2;
    int ans = 0;
    while(q--)
    {
        char h;
        int dest;
        cin >> h >> dest;
        if(h == 'R')
        {
            if((l < r && l < dest) || (l > r && l > dest))
            {
                ans += abs(dest - r);
                r = dest;
            }
            else
            {
                ans += n - abs(dest - r);
                r = dest;
            }
        }
        else
        {
            if((r < l && r < dest) || (r > l && r > dest))
            {
                ans += abs(dest - l);
                l = dest;
            }
            else
            {
                ans += n - abs(dest - l);
                l = dest;
            }
        }
    }

    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}